import type {
  ComponentRecordType,
  RouteRecordStringComponent,
} from '@vben/types';

import { baseUrlApi, requestClient } from '#/api/request';
import { convertArrayToNavigationTree } from '#/api/utils/routes';

/**
 * 获取用户所有菜单
 */
export async function getAllMenusApi(pageMap: ComponentRecordType) {
  return requestClient
    .get<RouteRecordStringComponent[]>(baseUrlApi('/admin/home/menus'))
    .then((res: any) => {
      const list = res?.data?.list;
      const menus = convertArrayToNavigationTree(list, pageMap) as any;
      console.warn(menus);

      return menus;
    });
}
